package edu.guet.server.controller;

import edu.guet.server.model.dto.NoticeDTO;
import edu.guet.server.model.vo.NoticeVO;
import edu.guet.server.service.NoticeService;
import edu.guet.server.utils.ResultAPI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping
public class NoticeController {
    private static final Logger log = LoggerFactory.getLogger(NoticeController.class);
    @Autowired
    private NoticeService noticeService;

    /**
     *增加公告
     * @param noticeDTO
     * @return
     */
    @PostMapping("/semester/addnotice")
    public ResultAPI addNotice(@RequestBody NoticeDTO noticeDTO) {

        // 处理接收到的参数，调用服务层方法等
        NoticeVO noticeVO = noticeService.addNotice(noticeDTO);
       return ResultAPI.success(noticeVO);
    }
    @GetMapping("/notice/showList")
    public ResultAPI showList(@RequestParam Integer semester_id) {
        //获取公告列表
        List<NoticeVO> showlist=noticeService.selectNotice(semester_id);
        return ResultAPI.success(showlist);
    }
    @DeleteMapping("/notice/{notice_id}")
    public ResultAPI deleteNotice(@PathVariable Integer notice_id) {
        noticeService.deleteNotice(notice_id);
        return ResultAPI.success();
    }
    @PutMapping("/notice/update")
    public ResultAPI updateNotice(@RequestBody NoticeDTO noticeDTO) {
        Integer ROW=noticeService.updateNotice(noticeDTO);
        log.info("行数：啊啊啊啊啊"+ROW);
        return ResultAPI.success();
    }
}
